package top.codedance.iotp.client.plugins.async.opc;

import org.eclipse.milo.opcua.stack.core.security.SecurityPolicy;

public enum BmSecurityPolicy {
    None(0), Basic128Rsa15(1), Basic256(2), Basic256Sha256(3), Aes128_Sha256_RsaOaep(4), Aes256_Sha256_RsaPss(5);
    private SecurityPolicy sp;
    private int key;

    BmSecurityPolicy(int key) {
        this.key = key;
        switch (key) {
            case 1:
                this.sp = SecurityPolicy.Basic128Rsa15;
                break;
            case 2:
                this.sp = SecurityPolicy.Basic256;
                break;
            case 3:
                this.sp = SecurityPolicy.Basic256Sha256;
                break;
            case 4:
                this.sp = SecurityPolicy.Aes128_Sha256_RsaOaep;
                break;
            case 5:
                this.sp = SecurityPolicy.Aes256_Sha256_RsaPss;
                break;
            case 0:
            default:
                this.sp = SecurityPolicy.None;
                break;
        }
    }

    public static SecurityPolicy valueOf(int key){
        BmSecurityPolicy[] values = values();
        for (BmSecurityPolicy bp : values){
            if(bp.key == key){
                return bp.sp;
            }
        }
        return null;
    }
}
